package javaTec.ThreadPrograming.childThread;

import java.util.concurrent.CountDownLatch;

/**
 * Created by yangshunxing on 2018/1/30.
 */
public class ChildThread {

    public static void main(String[] args) throws Exception {
        CountDownLatch end = new CountDownLatch(5);
        System.out.println("start。。。。");
        SleepTest[] threads = new SleepTest[10];
        for (SleepTest thread: threads){
            thread = new SleepTest(end);
            thread.run();
        }
//        end.await();
        System.out.println("end111111--------");
        System.out.println("end.....");

    }

    public static class SleepTest implements Runnable{
        CountDownLatch end;
        SleepTest(CountDownLatch latch){
            this.end = latch;
        }

        @Override
        public void run() {
            try {
                System.out.println(Thread.currentThread().getName()+"running...");
                Thread.sleep(1000);
//                end.countDown();
            }catch (Exception e){
                e.printStackTrace();
            }
        }
    }
}
